package com.foogui.dubbo;

import com.foogui.dto.CommodityDTO;
import com.foogui.service.StockService;
import io.seata.core.context.RootContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
@Slf4j
public class StockDubboServiceImpl implements StockDubboService {

    @Autowired
    private StockService stockService;

    @Override
    public Boolean reduce(CommodityDTO commodityDTO) {
        log.info("Dubbo服务-全局事务id ：" + RootContext.getXID());
        stockService.reduce(commodityDTO.getCommodityCode(),commodityDTO.getCount());
        return Boolean.TRUE;
    }
}
